package demo6;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-11-24
 * Time: 15:02
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        Map<String, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            String id = scanner.next();
            int l = scanner.nextInt();
            if(map.containsKey(id)) {
                map.put(id, map.get(id) + l);
            } else {
                map.put(id, l);
            }
        }
        int m = scanner.nextInt();
        for (int i = 0; i < m; i++) {
            String id = scanner.next();
            if(map.containsKey(id)) {
                if(map.get(id) < k) {
                    map.put(id, k);
                }
                System.out.println(map.get(id));
            } else {
                System.out.println("No Info");
            }
        }
    }
}
